//
//  ViewController.m
//  Homework_0509.2
//
//  Created by dllo on 16/5/9.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "Simpleitem.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self createitem];
    
}
- (void)createitem{
    
    
    Simpleitem *item  = [[Simpleitem alloc]initWithItems:@[@"登录",@"注册",@"忘记密码"]];
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    
    [self.view addSubview:view];
    
    [view release];
    
    view.backgroundColor = [UIColor blueColor];
    
    item.frame = CGRectMake(60, 300, 300, 50);
    [view addSubview:item];
    [item release];
    view.tag = 100;
    
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(50, 50, 50, 50)];
    [view addSubview:label];
    [label release];
    
    label.text = @"忘记密码";
    
    label.textColor = [UIColor blackColor];
    
    [item addTarget:self action:@selector(hangleitem:) forControlEvents:UIControlEventValueChanged];
    
    
    UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    [self.view addSubview:view1];
    [view1 release];
    view1.backgroundColor = [UIColor cyanColor];
    
    Simpleitem *item1  = [[Simpleitem alloc]initWithItems:@[@"登录",@"注册",@"忘记密码"]];
    item1.frame = CGRectMake(60, 300, 300, 50);
    [view1 addSubview:item1];
    [item1 release];
    view1.tag = 200;
    
    
    self.view.backgroundColor = [UIColor greenColor];
    
    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(50, 50, 50, 50)];
    
    [view1 addSubview:label1];
    [label1 release];
    
    label1.text = @"注册";
    
    label1.textColor = [UIColor redColor];
    
    [item1 addTarget:self action:@selector(hangleitem2:) forControlEvents:UIControlEventValueChanged];
    
    
    UIView *view2 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    [self.view addSubview:view2];
    [view2 release];

    view2.backgroundColor = [UIColor yellowColor];
    Simpleitem *item2  = [[Simpleitem alloc]initWithItems:@[@"登录",@"注册",@"忘记密码"]];
    view2.tag = 300;
    
    item2.frame = CGRectMake(60, 300, 300, 50);
    
    [view2 addSubview:item2];
    [item2 release];
   
    self.view.backgroundColor = [UIColor redColor];
    
    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(50, 50, 50, 50)];
    [view2 addSubview:label2];
    [label2 release];
    label2.text = @"登录";
   
    label2.textColor = [UIColor redColor];
    
    [item2 addTarget:self action:@selector(hangleitem3:) forControlEvents:UIControlEventValueChanged];
    
   
    
    
}


- (void)hangleitem:(Simpleitem *)item{
    
    if (item.selectedSegmentIndex == 0 ) {
        [self.view bringSubviewToFront:[self.view viewWithTag:300]];
        
    }
    if (item.selectedSegmentIndex == 1) {
        [self.view bringSubviewToFront:[self.view viewWithTag:200]];
            }
    if (item.selectedSegmentIndex == 2) {
        [self.view bringSubviewToFront:[self.view viewWithTag:100]];
            }
    
}

- (void)hangleitem2:(Simpleitem *)item{
    
    if (item.selectedSegmentIndex == 0 ) {
        [self.view bringSubviewToFront:[self.view viewWithTag:300]];
        
    }
    if (item.selectedSegmentIndex == 1) {
        [self.view bringSubviewToFront:[self.view viewWithTag:200]];
    }
    if (item.selectedSegmentIndex == 2) {
        [self.view bringSubviewToFront:[self.view viewWithTag:100]];
    }
    
}



- (void)hangleitem3:(Simpleitem *)item{
    
    if (item.selectedSegmentIndex == 0 ) {
        [self.view bringSubviewToFront:[self.view viewWithTag:300]];
        
    }
    if (item.selectedSegmentIndex == 1) {
        [self.view bringSubviewToFront:[self.view viewWithTag:200]];
    }
    if (item.selectedSegmentIndex == 2) {
        [self.view bringSubviewToFront:[self.view viewWithTag:100]];
    }
    
}
















@end
